<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title></title>
		<%@ include file="/jsp/front/common/header.jsp"%>
	</head>
	<body>
		<%@ include file="/jsp/front/common/nav.jsp"%>

		<div style="margin: auto; width: 985px;">
			<div class="MemberCenter">
				<div class="siteparttitle">
					<div class="gender"></div>
					<div class="info">
						<strong>您好:${member.name}</strong>&nbsp;&nbsp;[ 会员中心]&nbsp;&nbsp;[
						<a href="logout.html" class="lnk">退出</a>]
					</div>
					<div class="time"></div>
					<div style="clear: both;"></div>
				</div>

				<%@ include file="/jsp/front/member/memberNav.jsp"%>

				<div class="MemberMain">
					<div style="margin-right: 175px;">
						<div class="title">
							收货地址
						</div>
						<form id="member_addr" class="section" action="member_address_save.html" method="post">
							<input type="hidden" name="memberAddress.addrId" value="${memberAddress.addrId}" />
							<div class="FormWrap">
								<div class="division">
									<table width="100%" cellspacing="0" cellpadding="0" border="0" class="forform">
										<tbody>
											<tr>
												<th>
													<em>*</em>姓名：
												</th>
												<td>
													<input value="${memberAddress.name}" name="memberAddress.name" class="x-input inputstyle" />
												</td>
											</tr>
											<tr>
												<th>
													<em>*</em>手机：
												</th>
												<td>
													<input value="${memberAddress.mobile}" name="memberAddress.mobile" class="x-input inputstyle" />
												</td>
											</tr>
											<tr>
												<th>
													固定电话：
												</th>
												<td>
													<input name="memberAddress.tel" class="x-input inputstyle" value="${memberAddress.tel}" />
												</td>
											</tr>
										</tbody>
									</table>
								</div>
								<div class="division">
									<table width="100%" cellspacing="0" cellpadding="0" border="0" class="forform">

										<tr>
											<th>
												<em>*</em>地区：
											</th>
											<td>
												<input type="hidden" id="province_hidden" value="${memberAddress.province}" name="memberAddress.province" />
												<input type="hidden" id="city_hidden" value="${memberAddress.city}" name="memberAddress.city" />
												<input type="hidden" id="area_hidden" value="${memberAddress.area}" name="memberAddress.area" />
												<select id="memberAddress_province" onchange="findSubRegions(this,'member_city','province_hidden');$('#member_city_hidden').val('');">
													<option value="">
														请选择...
													</option>
													<c:forEach var="region" items="${systemRegionses}">
														<option value="${region.regionId}" <c:if test="${region.localName eq memberAddress.province }">selected="selected"</c:if>>
															${region.localName}
														</option>
													</c:forEach>
												</select>

												<select id="member_city" onchange="findSubRegions(this,'member_area','city_hidden')">
													<option value="">
														<c:if test="${empty memberAddress.city}">请选择...</c:if>
														<c:if test="${not empty memberAddress.city}">${memberAddress.city}</c:if>
													</option>
												</select>
												<select id="member_area" name="memberAddress.areaId" onchange="findSubRegions(this,'','area_hidden')">
													<option value="${memberAddress.area}">
														<c:if test="${not empty memberAddress.area}">${memberAddress.area}</c:if>
													</option>
												</select>
											</td>
										</tr>
										<tr>
											<th>
												<em>*</em>地址：
											</th>
											<td>
												<textarea cols="30" rows="2" name="memberAddress.addr" class="inputstyle">${memberAddress.addr}</textarea>
											</td>
										</tr>
										<tr>
											<th>
												<em>*</em>邮政编码：
											</th>
											<td>
												<input value="${memberAddress.zip}" name="memberAddress.zip" class="x-input inputstyle" />
											</td>
										</tr>
										<tr>
											<th>
												<em>*</em>是否默认：
											</th>
											<td>
												<select id="memberAddress_defaultAddr" name="memberAddress.defaultAddr">
													<option value="1">
														是
													</option>
													<option value="0">
														否
													</option>
												</select>
											</td>
										</tr>
										<tr>
											<th></th>
											<td>
												<input type="submit" value="保存" name="submit">
													<input type="button" value="取消" />
											</td>
										</tr>

									</table>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>



		<%@ include file="/jsp/front/common/footer.jsp"%>
		<script type="text/javascript" src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<script type="text/javascript">
 
 		 
 		$('#memberAddress_defaultAddr').val('${memberAddress.defaultAddr}');



	function findSubRegions(obj,subId,hiddenId) {
		var url = "<c:url value="/sys_region_list.html" />";  
		var regionId = $(obj).attr('value'); 
		if(regionId==''){
			return;
		}
		var text = $(obj).find("option:selected").text().trim();
		$('#'+hiddenId).attr('value',text); 
		 
		var params = {
			"regionId" : regionId
		};
		
		if(subId!=''){
			$.getJSON(url, params, function callback(data) {
				 var regions = data.systemRegionss;
				 $('#'+subId).html('');
				 var str = '<option value="">请选择...	</option>';	
				 $(regions).each(function(index, region) {
					 str += '<option value="' + region.regionId + '">' + region.localName + '</option>';
				 });
				 $('#'+subId).html(str);	
			});
		}
	}
	
	
</script>
	</body>
</html>